package homework12月9号补交.homework2.d16;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.lang.reflect.Method;
import java.util.List;

/**
 * @Version 1.0
 * @Author:zhaoJiaCai
 * @Date:2019/12/8 星期日   19:12
 */
public class Test {
    public static void main(String[] args) throws Exception{
        List<String> strings = FileUtils.readLines(new File("D:\\ldea dashuju\\day.12.6\\src\\czxy\\homework2\\d16\\data.properties"));

        Class<User> userClass = User.class;
        User user = userClass.newInstance();
        for (String string : strings) {
            String[] split = string.split("=");
            System.out.println("set"+split[0].substring(0,1).toUpperCase()+split[0].substring(1));
            Method method = userClass.getMethod("set"+split[0].substring(0,1).toUpperCase()+split[0].substring(1),String.class);
            method.invoke(user,split[1]);
        }

        System.out.println(user);

    }
}
